import Xalert from './x-alert.vue'
const plugin = {}
plugin.install = function (Vue) {
    (function () {
        Vue.prototype.$xalert = {
            vm: null,
            el: null,
            open (options = {}) {
                var Comp = Vue.extend(Xalert)
                this.vm = new Comp()
                this.vm.$mount()
                this.el = this.vm.$el
                document.body.appendChild(this.el)
                for (let att in options) {
                    this.vm[att] = options[att]
                }
            },
            close () {
                if (this.el) {
                    document.body.removeChild(this.el)
                    this.vm.$destroy()
                    this.el = null
                    this.vm = null
                }
            }
        }
    })()
}
export default plugin
